package com.oocl.euc.core.builder;

import com.oocl.euc.core.maintenance.model.Team;
import com.oocl.euc.core.maintenance.model.TeamEndorser;
import com.oocl.euc.core.maintenance.repository.TeamRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.List;

@Component
public class TeamBuilder {

    private Team team;

    @Autowired
    private TeamRepository teamRepository;

    public TeamBuilder defaultBuilder() {
        this.team = new Team();
        this.team.setName("TEST TEAM NAME");
        this.team.setDesc("TEST TEAM DESC");
        return this;
    }

    public TeamBuilder withTeamName(String teamName) {
        team.setName(teamName);
        return this;
    }

    public TeamBuilder withTeamDesc(String desc) {
        team.setDesc(desc);
        return this;
    }

    public TeamBuilder withTeamEndorsers(List<TeamEndorser> teamEndorserList) {
        team.setTeamEndorsers(teamEndorserList);
        return this;
    }

    public Team create() {
        return team;
    }

    public Team saveToDB() {
        teamRepository.save(team);
        return team;
    }
}
